package cn.cuilan.server.core;

import cn.cuilan.common.entity.ProtocolMessage;
import cn.cuilan.common.server.ProtocolMessageServer;
import cn.cuilan.common.server.ServerConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NetServerConfig {

    @Value("${net.server.port}")
    private int port;

    @Bean
    public ProtocolMessageServer<ProtocolMessage> netServer() {
        final ServerConfiguration configuration = ServerConfiguration.newBuilder()
                .addLoggingHandler()
                .build();
        // 创建server
        return new ProtocolMessageServer<>(port, configuration);
    }

}
